package itheima.com.TestThread;

public class Ticket extends Thread {
    private int count = 66;
    private Object obj = new Object();

    @Override
    public void run() {
        while (true) {
            synchronized (obj) {
                if (count <= 0) {
                    break;
                }else{
                    try {
                        Thread.sleep(20);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    count--;
                    System.out.println(Thread.currentThread().getName()+"再买票还剩下"+count+"张票");
                }
            }
        }
    }
}
